package com.xbsg.protocol.xf.entiy;

import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.util.*;

public class AppData {
    //2 part ，上传火灾报警信息，4上传火灾设备操作信息
    public String type_flag;
    public String object_num;
    public List<StatusInfoObject> status_objects;
    public OptInfoObject optInfoObject;

    public static class InfoObject{
        public String info_body;
        public String time_label = "";
/*        public String get_time_label(String str1){
            String[] strs = str1.split(" ");
            return null;
        }*/
        public String toStringDesc(){ return null ;}
    }

    public static class OptInfoObject extends InfoObject{
        public String device_type;
        public String device_address;
        public String opt_type;
        public String opter;

        @Override
        public String toString() {
            return "OptInfoObject{" +
                    "device_type='" + AppDataUtil.device_type_map.get(device_type) + '\'' +
                    ", device_address='" + device_address + '\'' +
                    ", opt_type='" + opt_type + '\'' +
                    ", opter='" + opter + '\'' +
                    ", time_label='" + time_label + '\'' +
                    '}';
        }

        @Override
        public String toStringDesc(){
            return "OptInfoObject{" +
                    "device_type='" + AppDataUtil.device_type_map.get(device_type) + '\'' +
                    ", device_address='" + device_address + '\'' +
                    ", opt_type='" + AppDataUtil.device_part_opt_map.get(opt_type) + '\'' +
                    ", opter='" + opter + '\'' +
                    ", time_label='" + time_label + '\'' +
                    '}';
        }
    }

    public static class StatusInfoObject extends InfoObject{
        public String device_type;
        public String device_address;
        public String part_type;
        public String part_address="";
        public String part_status;
        public String part_desc="";

        @Override
        public String toString() {
            return "StatusInfoObject{" +
                    "device_type='" + device_type + '\'' +
                    ", device_address='" + device_address + '\'' +
                    ", part_type='" + part_type + '\'' +
                    ", part_address='" + part_address + '\'' +
                    ", part_status='" + part_status + '\'' +
                    ", part_desc='" + part_desc + '\'' +
                    ", time_label='" + time_label + '\'' +
                    '}';
        }
        private String parse_part_desc(String part_desc){
            String parse_part_desc = AppDataUtil.gB18030ByteArrayToUtf8String(AppDataUtil.hexStringToBytes(part_desc,10));
            return parse_part_desc;
        }

        public String get_part_desc(){
            String parse_part_desc = AppDataUtil.gB18030ByteArrayToUtf8String(AppDataUtil.hexStringToBytes(this.part_desc,10));
            return parse_part_desc;
        }

        public String get_part_address(){
            return AppDataUtil.toASII(this.part_address);
        }
        @Override
        public String toStringDesc(){
            return "StatusInfoObject{" +
                    "device_type='" + AppDataUtil.device_type_map.get(device_type) + '\'' +
                    ", device_address='" + device_address + '\'' +
                    ", part_type='" + AppDataUtil.part_type_map.get(part_type) + '\'' +
                    ", part_address='" + AppDataUtil.toASII(part_address) + '\'' +
                    ", part_status='" + AppDataUtil.device_part_status_map.get(part_status) + '\'' +
                    ", part_desc='" + parse_part_desc(part_desc) + '\'' +
                    '}';
        }
    }

/*    public static void main(String[] args) {
        String body = "49 50 51 52 53 54 55 56 57 48 49 50 51 52 53 54 55 56 57 48 0 0 0 0 0 0 0 0 0 0 0 ";
        byte[] bytes = AppDataUtil.hexStringToBytes(body,10);
        try {
            String str = new String(bytes, "utf-8");
            System.out.println(str);

            String str1 = AppDataUtil.gB18030ByteArrayToUtf8String(bytes);
            System.out.println(str1);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

    }*/

}
